package com.ruoyi.saleManagement.saleRegisterInfo.service.impl;

import java.util.List;

import com.ruoyi.basicData.ruleSetting.service.RuleSettingService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.saleManagement.saleRegisterInfo.mapper.SaleRegisterInfoMapper;
import com.ruoyi.saleManagement.saleRegisterInfo.domain.SaleRegisterInfo;
import com.ruoyi.saleManagement.saleRegisterInfo.service.ISaleRegisterInfoService;

/**
 * 售后登记信息Service业务层处理
 * 
 * @author YiYuan
 * @date 2024-03-23
 */
@Service
@RequiredArgsConstructor
public class SaleRegisterInfoServiceImpl implements ISaleRegisterInfoService 
{
    private final SaleRegisterInfoMapper saleRegisterInfoMapper;
    private final RuleSettingService ruleSettingService;

    /**
     * 查询售后登记信息
     * 
     * @param registerId 售后登记信息主键
     * @return 售后登记信息
     */
    @Override
    public SaleRegisterInfo selectSaleRegisterInfoByRegisterId(String registerId)
    {
        return saleRegisterInfoMapper.selectSaleRegisterInfoByRegisterId(registerId);
    }

    /**
     * 查询售后登记信息列表
     * 
     * @param saleRegisterInfo 售后登记信息
     * @return 售后登记信息
     */
    @Override
    public List<SaleRegisterInfo> selectSaleRegisterInfoList(SaleRegisterInfo saleRegisterInfo)
    {
        return saleRegisterInfoMapper.selectSaleRegisterInfoList(saleRegisterInfo);
    }

    /**
     * 新增售后登记信息
     * 
     * @param saleRegisterInfo 售后登记信息
     * @return 结果
     */
    @Override
    public int insertSaleRegisterInfo(SaleRegisterInfo saleRegisterInfo)
    {
        //生成的单据ID
        String sale_register_id = ruleSettingService.genDocId(SaleRegisterInfo.class, "SALE_REGISTER_ID");
        saleRegisterInfo.setRegisterId(sale_register_id);
        return saleRegisterInfoMapper.insertSaleRegisterInfo(saleRegisterInfo);
    }

    /**
     * 修改售后登记信息
     * 
     * @param saleRegisterInfo 售后登记信息
     * @return 结果
     */
    @Override
    public int updateSaleRegisterInfo(SaleRegisterInfo saleRegisterInfo)
    {
        return saleRegisterInfoMapper.updateSaleRegisterInfo(saleRegisterInfo);
    }

    /**
     * 批量删除售后登记信息
     * 
     * @param registerIds 需要删除的售后登记信息主键
     * @return 结果
     */
    @Override
    public int deleteSaleRegisterInfoByRegisterIds(String[] registerIds)
    {
        return saleRegisterInfoMapper.deleteSaleRegisterInfoByRegisterIds(registerIds);
    }

    /**
     * 删除售后登记信息信息
     * 
     * @param registerId 售后登记信息主键
     * @return 结果
     */
    @Override
    public int deleteSaleRegisterInfoByRegisterId(String registerId)
    {
        return saleRegisterInfoMapper.deleteSaleRegisterInfoByRegisterId(registerId);
    }

    @Override
    public AjaxResult getRegisterInfo(String bicycleId) {
        List<SaleRegisterInfo> registerInfo = saleRegisterInfoMapper.getRegisterInfo(bicycleId);
        return AjaxResult.success(registerInfo);
    }
}
